package main.com.dhj.test03

import scala.util.Random


object test02 {

    // 插值器
    def main(args: Array[String]): Unit = {
        val name = "dhj";
        val pi = 3.1415926;


        var str01 = s"$name--${Random.nextLong}";
        var str011 = s"$name--${Random.nextLong}--$pi%.2f";
        var str0111 = s"First line\nSecond line";
        println(str01);
        println(str011);
        println(str0111);


        println("-------------------------------------------------------")


        var str02 = f"Pi is approximately $pi%.2f";
        println(str02);


        println("-------------------------------------------------------");
        var str03 = raw"First line\nSecond line"
        println(str03);

        println("-------------------------------------------------------6");
        var str04 = upper"HELLO, $name";
        println(str04);
    }


    // 自定义插值器
    implicit class MyInterpolator(val sc: StringContext) extends AnyVal {
        def upper(args: Any*): String = sc.s(args: _*).toUpperCase
    }

}
